#!/usr/bin/env python3
"""
Quick test for T2TT translation
"""

import requests
import json

def test_translation():
    """Test a simple Chinese to English translation"""
    
    url = "http://127.0.0.1:8000/t2tt/translate"
    
    test_data = {
        "text": "你好",
        "src_lang": "cmn",
        "tgt_lang": "eng"
    }
    
    print("Testing T2TT Translation...")
    print(f"Input: {test_data['text']}")
    print(f"Languages: {test_data['src_lang']} → {test_data['tgt_lang']}")
    
    try:
        response = requests.post(url, json=test_data, timeout=30)
        
        if response.status_code == 200:
            result = response.json()
            print("✅ Success!")
            print(f"Original: {result['original_text']}")
            print(f"Translation: {result['translated_text']}")
            print(f"Languages: {result['src_lang']} → {result['tgt_lang']}")
        else:
            print(f"❌ Error {response.status_code}")
            print(f"Response: {response.text}")
            
    except Exception as e:
        print(f"❌ Request failed: {e}")

def test_default():
    """Test with default parameters"""
    
    url = "http://127.0.0.1:8000/t2tt/translate"
    
    test_data = {
        "text": "今天天气很好"
    }
    
    print("\nTesting with defaults...")
    print(f"Input: {test_data['text']}")
    
    try:
        response = requests.post(url, json=test_data, timeout=30)
        
        if response.status_code == 200:
            result = response.json()
            print("✅ Success!")
            print(f"Original: {result['original_text']}")
            print(f"Translation: {result['translated_text']}")
            print(f"Languages: {result['src_lang']} → {result['tgt_lang']}")
        else:
            print(f"❌ Error {response.status_code}")
            print(f"Response: {response.text}")
            
    except Exception as e:
        print(f"❌ Request failed: {e}")

if __name__ == "__main__":
    test_translation()
    test_default()
